//
//  EDSDragEditView.m
//  DrivieSchoolStudents
//
//  Created by TangBin on 2019/5/27.
//  Copyright © 2019 班文政. All rights reserved.
//

#import "EDSDragEditView.h"

@interface EDSDragEditView ()

@property (nonatomic, strong) UIImageView *imgView;

@property (nonatomic, assign) BOOL isLeft;

@end

@implementation EDSDragEditView

- (instancetype)initWithFrame:(CGRect)frame Left:(BOOL)left
{
    self.backgroundColor = [UIColor clearColor];
    self.isLeft = left;
    return [self initWithFrame:frame];
}

- (void)initWithSubView
{
    [super initWithSubView];
    
    UIView *backView = [[UIView alloc] initWithFrame:self.bounds];
    backView.backgroundColor = [UIColor blackColor];
    backView.alpha = 0.6;
    [self addSubview:backView];
    
    
    CGRect frame = CGRectZero;
    if (self.isLeft)
    {
        frame = CGRectMake(self.width - 10, 0, 10, self.height);
    }
    else
    {
        frame = CGRectMake(0, 0, 10, self.height);
    }
    _imgView = [[UIImageView alloc] initWithFrame:frame];
    _imgView.backgroundColor = [UIColor whiteColor];
    [self addSubview:_imgView];
}

- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
    return [self pointInsideSelf:point];
}

- (BOOL)pointInsideSelf:(CGPoint)point
{
    CGRect relativeFrame = self.bounds;
    CGRect hitFrame = UIEdgeInsetsInsetRect(relativeFrame, _hitTestEdgeInsets);
    return CGRectContainsPoint(hitFrame, point);
}

- (BOOL)pointInsideImgView:(CGPoint)point
{
    CGRect relativeFrame = _imgView.frame;
    CGRect hitFrame = UIEdgeInsetsInsetRect(relativeFrame, _hitTestEdgeInsets);
    return CGRectContainsPoint(hitFrame, point);
}

@end
